import java.util.Comparator;
import java.util.Queue;
import java.util.PriorityQueue;

public class QueueHelper {
    static void printQueue() {
        Queue<User> q = new PriorityQueue<>(new UserComparator());
        // 添加3个元素到队列:
        q.offer(new User("Bob", "A2"));
        q.offer(new User("Alice", "A2"));
        q.offer(new User("Boss", "V1"));
        System.out.println(q.poll()); // Boss/V1
        System.out.println(q.poll()); // Bob/A1
        System.out.println(q.poll()); // Alice/A2
        System.out.println(q.poll()); // null,因为队列为空
    }
}

class UserComparator implements Comparator<User> {
    public int compare(User u1, User u2) {
        if (u1.number().charAt(0) == u2.number().charAt(0)) {
            // 如果两人的号都是A开头或者都是V开头,比较号的大小:
            String num1 = u1.number().substring(1);
            String num2 = u2.number().substring(1);
            return Integer.compare(Integer.parseInt(num1), Integer.parseInt(num2));
        }
        if (u1.number().charAt(0) == 'V') {
            // u1的号码是V开头,优先级高:
            return -1;
        } else {
            return 1;
        }
    }
}

record User(String name, String number) {

    public String toString() {
        return name + "/" + number;
    }
}
